package com.aptech.yuanhuabao.ui.start.presenter;

import com.aptech.yuanhuabao.api.soap.result.LoginResult;
import com.aptech.yuanhuabao.ui.start.contract.LoginContract;
import com.jaydenxiao.common.commonutils.LogUtils;

import rx.Observer;

/**
 * des:
 * Created by zhh_li
 * on 2017/1/5.
 */

public class LoginPresenter extends LoginContract.Presenter {
    private static final String LOG_TAG = "LoginPresenter";
    @Override
    public void loginCenter(String account, String pwd) {
        mModel.checkLogin(account, pwd).
                subscribe(new Observer<LoginResult>() {
                    @Override
                    public void onCompleted() {
                        LogUtils.logd(LOG_TAG, "onCompleted");
                    }

                    @Override
                    public void onError(Throwable e) {
                        LogUtils.logd(LOG_TAG, e.getMessage());
                    }

                    @Override
                    public void onNext(LoginResult loginResult) {
                        LogUtils.logd(LOG_TAG, loginResult.toString());
                        mView.getLoginResult(loginResult.getResult(), loginResult.isSucess());
                    }
                });
    }
}
